package com.mx.ai.sports.common.entity;


import lombok.Getter;

import java.time.LocalDateTime;

/**
 * 节假日
 *
 * @author Mengjiaxin
 * @date 2021/5/3 下午4:26
 */
public enum HolidayEnum {

    /**
     * 51劳动节
     */
    WUYI(LocalDateTime.parse("2021-05-01T00:00:00.000"), LocalDateTime.parse("2021-05-05T23:59:59.000")),
    /**
     * 端午节
     */
    DUANWU(LocalDateTime.parse("2021-06-12T00:00:00.000"), LocalDateTime.parse("2021-06-14T23:59:59.000")),
    /**
     * 101国庆节
     */
    SHIYI(LocalDateTime.parse("2021-10-01T00:00:00.000"), LocalDateTime.parse("2021-10-07T23:59:59.000"));

    /**
     * 开始日期
     */
    @Getter
    private LocalDateTime start;

    /**
     * 结束日期
     */
    @Getter
    private LocalDateTime end;

    HolidayEnum(LocalDateTime start, LocalDateTime end) {

        this.start = start;
        this.end = end;
    }

    /**
     * 判断是否是在时间范围
     *
     * @param current 当前时间
     * @return
     */
    public static boolean isHoliday(LocalDateTime current) {
        for (HolidayEnum holidayEnum : values()) {
            if(holidayEnum.getStart().isBefore(current) && current.isBefore(holidayEnum.getEnd())){
                return true;
            }
        }
        return false;
    }

}
